import CsvSource from "../../../src/data/source/vector/CsvSource";
import FeatureLayer from "../../../src/layer/vector/FeatureLayer";
import { LayerEventType } from "../../../src/event/EventType";

export function test_styled_feature_layer(earth){

    _test_csv_layer(earth);
}


function _test_csv_layer(earth){
    let sourceName = "csv";

    //1. 创建Source    
    earth.addSource(
        new CsvSource(sourceName, {
            //url : "/resource/csv/cities.csv",
            url : "/resource/csv/heatmap.csv",
            header : true,
            fields :  {
                x : "X",
                y : "Y"
            }
        })
    );
    let source = earth.getSource(sourceName);

    //2. 创建Layer，将Source作为Layer属性
    let layer = new FeatureLayer(sourceName, {
        source : source
    });

    layer.on(LayerEventType.LOADED, function(evt){
        earth.zoomTo(layer);
    });

    earth.addLayer(layer);    

    //earth.flyTo(layer);
    earth.zoomTo(layer);
}